<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui-2.4.2/src/css/layui.css">
    <script type="text/javascript" src="/jquery/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/layui-2.4.2/src/layui.js"></script>
</head>
<body>
    <div>
        <!--<div class="layui-row">-->
            <!--<div class="layui-form">-->
                <!--<div class="layui-form-item"-->
            <!--</div>-->
        <!--</div>-->
        <div class="layui-row">
            <table id="tripcar_order_view" lay-filter="tripcar_order_filter">

            </table>
        </div>
    </div>

</body>
<script>
    layui.use(['element','table','upload','laytpl','form'], function() {
        var table=layui.table;
        table.render({
            elem:'#tripcar_order_view',
            url:'/tripcarOrder/queryList',
            page:true,
            limit:10,
            limits:[10,20,50,100],
            cols:[
                [
                    {field:'tripCarOrderId',title:'订单编号', width: 200},
                    {field:'tripCarType',title:'订单类型',templet:function(d){
                            if(d.tripCarType===1)return '接机';
                            if(d.tripCarType===2)return '送机';
                    }},
                    {field:'serviceDate',title:'服务日期', width: 120},
                    {field:'cityName',title:'城市', width: 120},
                    {field:'flightInfo',title:'航班信息', width: 120},
                    {field:'pickUp',title:'出发地点', width: 120},
                    {field:'destination',title:'送达地点', width: 120},
                    {field: 'orderType', title: '订单类型', width: 120, templet: function (d) {
                            var orderType = "";
                            if (d.orderType === 1){
                                orderType = "RMB支付";
                            }
                            if (d.orderType === 2){
                                orderType = "FMT支付";
                            }
                            if (d.orderType === 3){
                                orderType = "混合支付";
                            }
                            if (d.orderType === 4){
                                orderType = "后台搬单";
                            }
                            return orderType
                        }},
                    {field: 'honeySugar', title: '订单金额', width: 120, templet: function (d) {
                            var money = d.honeySugar+"RMB";
                            return money
                        }},
                    {field: 'countFmt', title: 'FMT金额', width: 120},
                    {field: 'deductionFmtAmount', title: '用来抵扣的FMT数量', width: 200, templet: function (d) {
                            var money = "用"+d.deductionFmtAmount+"FMT抵扣"+d.fmtDeductionRmb+"的RMB";
                            if (d.deductionFmtAmount === 0 && d.fmtDeductionRmb===0){
                                money = "未使用抵扣";
                            }
                            return money
                        }},
                    {field: 'paidHoneySugar', title: '实付金额', width: 120, templet: function (d) {
                            var money = "";
                            if (d.orderType === 1){
                                money = d.paidHoneySugar+"RMB";
                            }
                            if (d.orderType === 2){
                                money = d.paidHoneySugar+"FMT";
                            }
                            return money
                        }},
                    {field:'honeySugar',title:'价格/元', width: 120},
                    {field:'mobile',title:'联系电话', width: 120},
                    {field:'status',title:'状态', width: 120,templet:function(d){
                        if(d.status===0)return '取消';
                        if(d.status===1)return '下单成功';
                        if(d.status===2)return '支付成功';
                        if(d.status===3)return '确认用车';
                        if(d.status===4)return '完成';
                        if(d.status===5)return '订单超时过期';
                    }},
                    {field:'right',align:'center',title:'操作',toolbar:'#toolOper', width: 120}

                ]
            ],
            response:{
                status:'errorCode',
                countName:'total',
                dataName:'data'
            }
        });

        table.on('tool(tripcar_order_filter)',function(obj){
            var data=obj.data;
            var layEvent=obj.event;
            var data;
            if(layEvent==='cancel'){
                data = {'tripCarOrderId':data.tripCarOrderId,status:0};
            }
            if (layEvent==='finsh') {
                data = {'tripCarOrderId':data.tripCarOrderId,status:4};
            }
            $.ajax({
                type:'get',
                data:data,
                url:'/tripcarOrder/updateStatus',
                cache:false,
                success:function (data) {
                    $(".layui-laypage-btn").click();
                }
            });
        });
    });
</script>
<script type="text/html" id="toolOper">
    {{#  if(d.status == 2 ){ }}
    <a class="layui-btn layui-btn-xs" lay-event="finsh">完成</a>
    {{#  } }}
    {{#  if(d.status < 3&d.status > 0 ){ }}
    <a class="layui-btn layui-btn-xs" lay-event="cancel">取消</a>
    {{#  } }}
</script>
</html>